package com.cryptoneedle.center.source.helper;

import cn.hutool.v7.extra.spring.SpringUtil;
import com.cryptoneedle.center.source.constants.ConfigPropertyConstants;
import com.cryptoneedle.center.source.repository.ConfigPropertyRepository;

/**
 * <p>description: 配置属性 工具类 </p>
 *
 * @author CryptoNeedle
 * @date 2025-09-25
 */
public class ConfigPropertyHelper {

    private static ConfigPropertyRepository getRepository() {
        return SpringUtil.getBean(ConfigPropertyRepository.class);
    }

    public static String ods() {
        return getValue(ConfigPropertyConstants.DORIS_DATABASE_ODS);
    }

    public static String dwd() {
        return getValue(ConfigPropertyConstants.DORIS_DATABASE_DWD);
    }

    public static String dws() {
        return getValue(ConfigPropertyConstants.DORIS_DATABASE_DWS);
    }

    public static String ads() {
        return getValue(ConfigPropertyConstants.DORIS_DATABASE_ADS);
    }

    public static String dim() {
        return getValue(ConfigPropertyConstants.DORIS_DATABASE_DIM);
    }

    public static String mapping() {
        return getValue(ConfigPropertyConstants.DORIS_DATABASE_MAPPING);
    }

    private static String getValue(String name) {
        String value = getRepository().getValue(name);
        if (value == null) {
            throw new RuntimeException("Doris Config 未配置：%s".formatted(name));
        }
        return value;
    }
}